/*************************************************************************
 * Copyright 2008 David Almilli
 *  
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 *  
 *     http://www.apache.org/licenses/LICENSE-2.0 
 *      
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License.
 **************************************************************************/
package com.tivo.hme.bananas;

import com.tivo.hme.bananas.BKeyboardPlus.Cell;
import com.tivo.hme.bananas.BSkinPlus.Element;
import com.tivo.hme.sdk.Resolution;
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;

public class SkinUtils {

    public static final Color tivoWhite = new Color(235, 235, 235);
    public static final Color tivoYellow = new Color(221, 182, 0);
    public static final Color tivoGreen = new Color(49, 183, 28);
    
	public static void init(BSkinPlus skin, Resolution res) {

		synchronized(skin) {
			initScaled(skin, res);
		}
	}
	
	private static void initScaled(BSkinPlus skin, Resolution res) {
        Element e;
        String prefix = "com/tivo/hme/bananas/images720/";
        Scale s = new Scale(720, res.getHeight());
        Scale f;
        if (res.getHeight() < 720) {
            //do a lighter scale for fonts when it's a smaller resolution
            f = new Scale(720, res.getHeight()*9/8);
        } else {
            f = s;
        }

        // whispering arrows
        createImage(skin, s, IBananasPlus.H_UP,    40, 40, prefix + "up.png");
        createImage(skin, s, IBananasPlus.H_DOWN,  40, 40, prefix + "down.png");
        createImage(skin, s, IBananasPlus.H_LEFT,  40, 40, prefix + "left.png");
        createImage(skin, s, IBananasPlus.H_RIGHT, 40, 40, prefix + "right.png");

        // highlight bar
        e = createImage(skin, s, IBananasPlus.H_BAR, 1280, 58, prefix + "bar.png");
        e.setInt(IBananasPlus.P_CAP, s.dx(35));
        e.setInt(IBananasPlus.P_PAD_H, s.dx(25));
        e.setInt(IBananasPlus.P_PAD_V, s.dx(4));

        // disabled bar
        e = createImage(skin, s, IBananasPlus.H_BAR_DISABLED, 1280, 58, prefix + "bar_disabled.png");
        e.setInt(IBananasPlus.P_CAP, s.dx(35));
        e.setInt(IBananasPlus.P_PAD_H, s.dx(25));
        e.setInt(IBananasPlus.P_PAD_V, s.dx(4));
        
        new Element(skin, IBananasPlus.H_BAR_FONT, 0, 0, "default-" + f.dx(32) + ".font");
        new Element(skin, IBananasPlus.H_BAR_TEXT_COLOR, 0, 0, tivoWhite);
        
        // text
        new Element(skin, IBananasPlus.H_PARAGRAPH_FONT, 0, 0, "default-" + f.dx(24) + ".font");
        new Element(skin, IBananasPlus.H_PARAGRAPH_TEXT_COLOR, 0, 0, tivoWhite);
        new Element(skin, IBananasPlus.H_TITLE_FONT, 0, 0, "default-" + f.dx(48) + ".font");
        new Element(skin, IBananasPlus.H_TITLE_TEXT_COLOR, 0, 0, tivoYellow);
        new Element(skin, IBananasPlus.H_TITLE_SHADOW_COLOR, 0, 0, Color.black);

        // page up/down
        createImage(skin, s, IBananasPlus.H_PAGEUP,   24, 27, prefix + "pageup.png");
        createImage(skin, s, IBananasPlus.H_PAGEDOWN, 24, 27, prefix + "pagedown.png");
        
        // shuttle bar
        e = createImage(skin, s, IBananasPlus.H_SHUTTLEBAR, 905, 45, prefix + "shuttlebar.png");
        e.setInt(IBananasPlus.P_CAP, s.dx(97));
        e.setInt(IBananasPlus.P_PAD_V, s.dx(14));
        
        e = createImage(skin, s, IBananasPlus.H_SHUTTLEBAR_SHUTTLE_TOP, 130, 20, 
                prefix + "shuttlebar_shuttle_top.png");
        
        e = createImage(skin, s, IBananasPlus.H_SHUTTLEBAR_SHUTTLE_BOTTOM, 130, 25, 
                prefix + "shuttlebar_shuttle_bottom.png");
        
        e = createImage(skin, s, IBananasPlus.H_SHUTTLEBAR_MARKER, 10, 20, 
                prefix + "shuttlebar_marker.png");
        e.setInt(IBananasPlus.P_PAD_V, s.dx(34));
        e.setInt(IBananasPlus.P_PAD_H, s.dx(60));
        
        e = new Element(skin, IBananasPlus.H_SHUTTLEBAR_PROGRESS, 640, s.dx(20), tivoGreen);

        e = createImage(skin, s, IBananasPlus.H_SHUTTLEBAR_TICK, 5, 9, prefix + "shuttlebar_tick.png");

        // shuttle play modes
        e = createImage(skin, s, IBananasPlus.H_SHUTTLEBAR_MODE_PREFIX + BShuttleBarPlus.MODE_PLAY, 
        		10, 16, prefix + "shuttlebar_mode_play.png");
        e.setInt(IBananasPlus.P_PAD_V, s.dx(68));
        e.setInt(IBananasPlus.P_PAD_H, s.dx(60));
        
        e = createImage(skin, s, IBananasPlus.H_SHUTTLEBAR_MODE_PREFIX + BShuttleBarPlus.MODE_PAUSE, 
                10, 14, prefix + "shuttlebar_mode_pause.png");
        e.setInt(IBananasPlus.P_PAD_V, s.dx(69));
        e.setInt(IBananasPlus.P_PAD_H, s.dx(60));
        
        e = createImage(skin, s, IBananasPlus.H_SHUTTLEBAR_MODE_PREFIX + BShuttleBarPlus.MODE_STOP, 
        		10, 14, prefix + "shuttlebar_mode_stop.png");
        e.setInt(IBananasPlus.P_PAD_V, s.dx(69));
        e.setInt(IBananasPlus.P_PAD_H, s.dx(60));
        
        e = createImage(skin, s, IBananasPlus.H_SHUTTLEBAR_MODE_PREFIX + BShuttleBarPlus.MODE_SLOW, 
                16, 16, prefix + "shuttlebar_mode_slow.png");
        e.setInt(IBananasPlus.P_PAD_V, s.dx(68));
        e.setInt(IBananasPlus.P_PAD_H, s.dx(60));
        
        e = createImage(skin, s, IBananasPlus.H_SHUTTLEBAR_MODE_PREFIX + BShuttleBarPlus.MODE_FORWARD1, 
        		36, 16, prefix + "shuttlebar_mode_fwd1.png");
        e.setInt(IBananasPlus.P_PAD_V, s.dx(68));
        e.setInt(IBananasPlus.P_PAD_H, s.dx(47));
        
        e = createImage(skin, s, IBananasPlus.H_SHUTTLEBAR_MODE_PREFIX + BShuttleBarPlus.MODE_FORWARD2, 
        		36, 16, prefix + "shuttlebar_mode_fwd2.png");
        e.setInt(IBananasPlus.P_PAD_V, s.dx(68));
        e.setInt(IBananasPlus.P_PAD_H, s.dx(47));
        
        e = createImage(skin, s, IBananasPlus.H_SHUTTLEBAR_MODE_PREFIX + BShuttleBarPlus.MODE_FORWARD3, 
        		36, 16, prefix + "shuttlebar_mode_fwd3.png");
        e.setInt(IBananasPlus.P_PAD_V, s.dx(68));
        e.setInt(IBananasPlus.P_PAD_H, s.dx(47));
        
        e = createImage(skin, s, IBananasPlus.H_SHUTTLEBAR_MODE_PREFIX + BShuttleBarPlus.MODE_REVERSE1, 
        		36, 16, prefix + "shuttlebar_mode_rev1.png");
        e.setInt(IBananasPlus.P_PAD_V, s.dx(68));
        e.setInt(IBananasPlus.P_PAD_H, s.dx(46));
        
        e = createImage(skin, s, IBananasPlus.H_SHUTTLEBAR_MODE_PREFIX + BShuttleBarPlus.MODE_REVERSE2, 
        		36, 16, prefix + "shuttlebar_mode_rev2.png");
        e.setInt(IBananasPlus.P_PAD_V, s.dx(68));
        e.setInt(IBananasPlus.P_PAD_H, s.dx(46));
        
        e = createImage(skin, s, IBananasPlus.H_SHUTTLEBAR_MODE_PREFIX + BShuttleBarPlus.MODE_REVERSE3, 
        		36, 16, prefix + "shuttlebar_mode_rev3.png");
        e.setInt(IBananasPlus.P_PAD_V, s.dx(68));
        e.setInt(IBananasPlus.P_PAD_H, s.dx(46));

        new Element(skin, IBananasPlus.H_SHUTTLEBAR_FONT, 0, 0, "default-" + f.dx(24) + "-bold.font");
        new Element(skin, IBananasPlus.H_SHUTTLEBAR_COLOR, 0, 0, tivoWhite);
        
        //please wait
        createImage(skin, s, IBananasPlus.H_PLEASE_WAIT, 263, 149, prefix + "pleasewait.png");
        
        //install keyboards
        createLowercaseKeyboard(skin, prefix, s, f);
        createUppercaseKeyboard(skin, prefix, s, f);
        createSymbolKeyboard(skin, prefix, s, f);
        createEmailUrlLowercaseKeyboard(skin, prefix, s, f, "email");
        createEmailUrlUppercaseKeyboard(skin, prefix, s, f, "email");
        createEmailUrlSymbolKeyboard(skin, prefix, s, f, "email");
        createEmailUrlLowercaseKeyboard(skin, prefix, s, f, "url");
        createEmailUrlUppercaseKeyboard(skin, prefix, s, f, "url");
        createEmailUrlSymbolKeyboard(skin, prefix, s, f, "url");
        
        createTallKeyboard(skin, prefix, s, f);
        
        // keyboard highlight
        e = createImage(skin, s, IBananasPlus.H_KEYBOARD, 86, 53, prefix + "keyboard-focus.png");
        e.setInt(IBananasPlus.P_CAP, s.dx(10));
        e.setInt(IBananasPlus.P_PAD_H, s.dx(6));
        e.setInt(IBananasPlus.P_PAD_V, s.dx(6));
	}

    private static void createLowercaseKeyboard(BSkinPlus skin, String prefix, Scale s, Scale f) {
        Cell cells[][] = new Cell[9][5];

        // row 1
        cells[0][0] = new Cell(Cell.CELL_TYPE_DEL, null, s.dx(12), s.dx(12), s.dx(58), s.dx(34));
        cells[1][0] = new Cell(Cell.CELL_TYPE_CLR, null, s.dx(84), s.dx(12), s.dx(90), s.dx(34));
        cells[2][0] = new Cell(Cell.CELL_TYPE_CHAR, " ", s.dx(184), s.dx(12), s.dx(65), s.dx(34));
        cells[3][0] = new Cell(Cell.CELL_TYPE_KEYBOARD, BKeyboardPlus.UPPERCASE, s.dx(272), s.dx(12), s.dx(68), s.dx(34));
        cells[4][0] = new Cell(Cell.CELL_TYPE_KEYBOARD, BKeyboardPlus.SYMBOL, s.dx(354), s.dx(12), s.dx(69), s.dx(34));

        // row 2-5
        createLowercaseCells(cells, s);

        String top_img = prefix + "keyboard-top-DELCLRSPC_ABC_SYM.png";
        String top_undo_img = prefix + "keyboard-top-DELUNDOSPC_ABC_SYM.png";
        String middle_img = prefix + "keyboard-middle-lc.png";
        String bottom_img = prefix + "keyboard-bottom-empty.png";
        String data_img = prefix + "keyboard-datafield.png";
        String tips_img = prefix + "keyboard-tips.png";
    
        createKeyboard(skin, s, f, BKeyboardPlus.LOWERCASE, cells, 
                top_img, top_undo_img, 53,
                middle_img, 180,
                bottom_img, 17,
                data_img, 304, 54, 15, 7,
                tips_img, 207, 209, 16, 30,
                434, 32, tivoWhite);
    }
    
    private static void createLowercaseCells(Cell[][] cells, Scale s) {
        // row 2
        cells[0][1] = new Cell(Cell.CELL_TYPE_CHAR, "a", s.dx(13), s.dx(58), s.dx(45), s.dx(42));
        cells[1][1] = new Cell(Cell.CELL_TYPE_CHAR, "b", s.dx(58), s.dx(58), s.dx(45), s.dx(42));
        cells[2][1] = new Cell(Cell.CELL_TYPE_CHAR, "c", s.dx(103), s.dx(58), s.dx(45), s.dx(42));
        cells[3][1] = new Cell(Cell.CELL_TYPE_CHAR, "d", s.dx(148), s.dx(58), s.dx(45), s.dx(42));
        cells[4][1] = new Cell(Cell.CELL_TYPE_CHAR, "e", s.dx(193), s.dx(58), s.dx(45), s.dx(42));
        cells[5][1] = new Cell(Cell.CELL_TYPE_CHAR, "f", s.dx(238), s.dx(58), s.dx(45), s.dx(42));
        cells[6][1] = new Cell(Cell.CELL_TYPE_CHAR, "g", s.dx(283), s.dx(58), s.dx(45), s.dx(42));
        cells[7][1] = new Cell(Cell.CELL_TYPE_CHAR, "h", s.dx(328), s.dx(58), s.dx(45), s.dx(42));
        cells[8][1] = new Cell(Cell.CELL_TYPE_CHAR, "i", s.dx(373), s.dx(58), s.dx(45), s.dx(42));

        // row 3
        cells[0][2] = new Cell(Cell.CELL_TYPE_CHAR, "j", s.dx(13), s.dx(103), s.dx(45), s.dx(42));
        cells[1][2] = new Cell(Cell.CELL_TYPE_CHAR, "k", s.dx(58), s.dx(103), s.dx(45), s.dx(42));
        cells[2][2] = new Cell(Cell.CELL_TYPE_CHAR, "l", s.dx(103), s.dx(103), s.dx(45), s.dx(42));
        cells[3][2] = new Cell(Cell.CELL_TYPE_CHAR, "m", s.dx(148), s.dx(103), s.dx(45), s.dx(42));
        cells[4][2] = new Cell(Cell.CELL_TYPE_CHAR, "n", s.dx(193), s.dx(103), s.dx(45), s.dx(42));
        cells[5][2] = new Cell(Cell.CELL_TYPE_CHAR, "o", s.dx(238), s.dx(103), s.dx(45), s.dx(42));
        cells[6][2] = new Cell(Cell.CELL_TYPE_CHAR, "p", s.dx(283), s.dx(103), s.dx(45), s.dx(42));
        cells[7][2] = new Cell(Cell.CELL_TYPE_CHAR, "q", s.dx(328), s.dx(103), s.dx(45), s.dx(42));
        cells[8][2] = new Cell(Cell.CELL_TYPE_CHAR, "r", s.dx(373), s.dx(103), s.dx(45), s.dx(42));

        // row 4
        cells[0][3] = new Cell(Cell.CELL_TYPE_CHAR, "s", s.dx(13), s.dx(151), s.dx(45), s.dx(42));
        cells[1][3] = new Cell(Cell.CELL_TYPE_CHAR, "t", s.dx(58), s.dx(151), s.dx(45), s.dx(42));
        cells[2][3] = new Cell(Cell.CELL_TYPE_CHAR, "u", s.dx(103), s.dx(151), s.dx(45), s.dx(42));
        cells[3][3] = new Cell(Cell.CELL_TYPE_CHAR, "v", s.dx(148), s.dx(151), s.dx(45), s.dx(42));
        cells[4][3] = new Cell(Cell.CELL_TYPE_CHAR, "w", s.dx(193), s.dx(151), s.dx(45), s.dx(42));
        cells[5][3] = new Cell(Cell.CELL_TYPE_CHAR, "x", s.dx(238), s.dx(151), s.dx(45), s.dx(42));
        cells[6][3] = new Cell(Cell.CELL_TYPE_CHAR, "y", s.dx(283), s.dx(151), s.dx(45), s.dx(42));
        cells[7][3] = new Cell(Cell.CELL_TYPE_CHAR, "z", s.dx(328), s.dx(151), s.dx(45), s.dx(42));
        cells[8][3] = new Cell(Cell.CELL_TYPE_CHAR, "0", s.dx(373), s.dx(151), s.dx(45), s.dx(42));

        // row 5
        cells[0][4] = new Cell(Cell.CELL_TYPE_CHAR, "1", s.dx(13), s.dx(196), s.dx(45), s.dx(45));
        cells[1][4] = new Cell(Cell.CELL_TYPE_CHAR, "2", s.dx(58), s.dx(196), s.dx(45), s.dx(45));
        cells[2][4] = new Cell(Cell.CELL_TYPE_CHAR, "3", s.dx(103), s.dx(196), s.dx(45), s.dx(45));
        cells[3][4] = new Cell(Cell.CELL_TYPE_CHAR, "4", s.dx(148), s.dx(196), s.dx(45), s.dx(45));
        cells[4][4] = new Cell(Cell.CELL_TYPE_CHAR, "5", s.dx(193), s.dx(196), s.dx(45), s.dx(45));
        cells[5][4] = new Cell(Cell.CELL_TYPE_CHAR, "6", s.dx(238), s.dx(196), s.dx(45), s.dx(45));
        cells[6][4] = new Cell(Cell.CELL_TYPE_CHAR, "7", s.dx(283), s.dx(196), s.dx(45), s.dx(45));
        cells[7][4] = new Cell(Cell.CELL_TYPE_CHAR, "8", s.dx(328), s.dx(196), s.dx(45), s.dx(45));
        cells[8][4] = new Cell(Cell.CELL_TYPE_CHAR, "9", s.dx(373), s.dx(196), s.dx(45), s.dx(45));
    }
    
    private static void createUppercaseKeyboard(BSkinPlus skin, String prefix, Scale s, Scale f) {
        Cell cells[][] = new Cell[9][5];
        
        // row 1
        cells[0][0] = new Cell(Cell.CELL_TYPE_DEL, null, s.dx(12), s.dx(12), s.dx(58), s.dx(34));
        cells[1][0] = new Cell(Cell.CELL_TYPE_CLR, null, s.dx(84), s.dx(12), s.dx(90), s.dx(34));
        cells[2][0] = new Cell(Cell.CELL_TYPE_CHAR, " ", s.dx(184), s.dx(12), s.dx(65), s.dx(34));
        cells[3][0] = new Cell(Cell.CELL_TYPE_KEYBOARD, BKeyboardPlus.LOWERCASE, s.dx(272), s.dx(12), s.dx(68), s.dx(34));
        cells[4][0] = new Cell(Cell.CELL_TYPE_KEYBOARD, BKeyboardPlus.SYMBOL, s.dx(354), s.dx(12), s.dx(69), s.dx(34));

        // row 2-5
        createUppercaseCells(cells, s);

        String top_img = prefix + "keyboard-top-DELCLRSPCabcSYM.png";
        String top_undo_img = prefix + "keyboard-top-DELUNDOSPCabcSYM.png";
        String middle_img = prefix + "keyboard-middle-uc.png";
        String bottom_img = prefix + "keyboard-bottom-empty.png";
        String data_img = prefix + "keyboard-datafield.png";
        String tips_img = prefix + "keyboard-tips.png";
    
        createKeyboard(skin, s, f, BKeyboardPlus.UPPERCASE, cells, 
                top_img, top_undo_img, 53,
                middle_img, 180,
                bottom_img, 17,
                data_img, 304, 54, 15, 7,
                tips_img, 207, 209, 16, 30,
                434, 32, tivoWhite);
    }
    
    private static void createUppercaseCells(Cell[][] cells, Scale s) {
        // row 2
        cells[0][1] = new Cell(Cell.CELL_TYPE_CHAR, "A", s.dx(13), s.dx(58), s.dx(45), s.dx(42));
        cells[1][1] = new Cell(Cell.CELL_TYPE_CHAR, "B", s.dx(58), s.dx(58), s.dx(45), s.dx(42));
        cells[2][1] = new Cell(Cell.CELL_TYPE_CHAR, "C", s.dx(103), s.dx(58), s.dx(45), s.dx(42));
        cells[3][1] = new Cell(Cell.CELL_TYPE_CHAR, "D", s.dx(148), s.dx(58), s.dx(45), s.dx(42));
        cells[4][1] = new Cell(Cell.CELL_TYPE_CHAR, "E", s.dx(193), s.dx(58), s.dx(45), s.dx(42));
        cells[5][1] = new Cell(Cell.CELL_TYPE_CHAR, "F", s.dx(238), s.dx(58), s.dx(45), s.dx(42));
        cells[6][1] = new Cell(Cell.CELL_TYPE_CHAR, "G", s.dx(283), s.dx(58), s.dx(45), s.dx(42));
        cells[7][1] = new Cell(Cell.CELL_TYPE_CHAR, "H", s.dx(328), s.dx(58), s.dx(45), s.dx(42));
        cells[8][1] = new Cell(Cell.CELL_TYPE_CHAR, "I", s.dx(373), s.dx(58), s.dx(45), s.dx(42));

        // row 3
        cells[0][2] = new Cell(Cell.CELL_TYPE_CHAR, "J", s.dx(13), s.dx(103), s.dx(45), s.dx(42));
        cells[1][2] = new Cell(Cell.CELL_TYPE_CHAR, "K", s.dx(58), s.dx(103), s.dx(45), s.dx(42));
        cells[2][2] = new Cell(Cell.CELL_TYPE_CHAR, "L", s.dx(103), s.dx(103), s.dx(45), s.dx(42));
        cells[3][2] = new Cell(Cell.CELL_TYPE_CHAR, "M", s.dx(148), s.dx(103), s.dx(45), s.dx(42));
        cells[4][2] = new Cell(Cell.CELL_TYPE_CHAR, "N", s.dx(193), s.dx(103), s.dx(45), s.dx(42));
        cells[5][2] = new Cell(Cell.CELL_TYPE_CHAR, "O", s.dx(238), s.dx(103), s.dx(45), s.dx(42));
        cells[6][2] = new Cell(Cell.CELL_TYPE_CHAR, "P", s.dx(283), s.dx(103), s.dx(45), s.dx(42));
        cells[7][2] = new Cell(Cell.CELL_TYPE_CHAR, "Q", s.dx(328), s.dx(103), s.dx(45), s.dx(42));
        cells[8][2] = new Cell(Cell.CELL_TYPE_CHAR, "R", s.dx(373), s.dx(103), s.dx(45), s.dx(42));

        // row 4
        cells[0][3] = new Cell(Cell.CELL_TYPE_CHAR, "S", s.dx(13), s.dx(151), s.dx(45), s.dx(42));
        cells[1][3] = new Cell(Cell.CELL_TYPE_CHAR, "T", s.dx(58), s.dx(151), s.dx(45), s.dx(42));
        cells[2][3] = new Cell(Cell.CELL_TYPE_CHAR, "U", s.dx(103), s.dx(151), s.dx(45), s.dx(42));
        cells[3][3] = new Cell(Cell.CELL_TYPE_CHAR, "V", s.dx(148), s.dx(151), s.dx(45), s.dx(42));
        cells[4][3] = new Cell(Cell.CELL_TYPE_CHAR, "W", s.dx(193), s.dx(151), s.dx(45), s.dx(42));
        cells[5][3] = new Cell(Cell.CELL_TYPE_CHAR, "X", s.dx(238), s.dx(151), s.dx(45), s.dx(42));
        cells[6][3] = new Cell(Cell.CELL_TYPE_CHAR, "Y", s.dx(283), s.dx(151), s.dx(45), s.dx(42));
        cells[7][3] = new Cell(Cell.CELL_TYPE_CHAR, "Z", s.dx(328), s.dx(151), s.dx(45), s.dx(42));
        cells[8][3] = new Cell(Cell.CELL_TYPE_CHAR, "0", s.dx(373), s.dx(151), s.dx(45), s.dx(42));

        // row 5
        cells[0][4] = new Cell(Cell.CELL_TYPE_CHAR, "1", s.dx(13), s.dx(196), s.dx(45), s.dx(45));
        cells[1][4] = new Cell(Cell.CELL_TYPE_CHAR, "2", s.dx(58), s.dx(196), s.dx(45), s.dx(45));
        cells[2][4] = new Cell(Cell.CELL_TYPE_CHAR, "3", s.dx(103), s.dx(196), s.dx(45), s.dx(45));
        cells[3][4] = new Cell(Cell.CELL_TYPE_CHAR, "4", s.dx(148), s.dx(196), s.dx(45), s.dx(45));
        cells[4][4] = new Cell(Cell.CELL_TYPE_CHAR, "5", s.dx(193), s.dx(196), s.dx(45), s.dx(45));
        cells[5][4] = new Cell(Cell.CELL_TYPE_CHAR, "6", s.dx(238), s.dx(196), s.dx(45), s.dx(45));
        cells[6][4] = new Cell(Cell.CELL_TYPE_CHAR, "7", s.dx(283), s.dx(196), s.dx(45), s.dx(45));
        cells[7][4] = new Cell(Cell.CELL_TYPE_CHAR, "8", s.dx(328), s.dx(196), s.dx(45), s.dx(45));
        cells[8][4] = new Cell(Cell.CELL_TYPE_CHAR, "9", s.dx(373), s.dx(196), s.dx(45), s.dx(45));   
    }
    
    private static void createTallKeyboard(BSkinPlus skin, String prefix, Scale s, Scale f) {
        Cell cells[][] = new Cell[4][10];
        
        // row 1
        cells[0][0] = new Cell(Cell.CELL_TYPE_DEL, null, s.dx(11), s.dx(6), s.dx(54), s.dx(34));
        cells[1][0] = new Cell(Cell.CELL_TYPE_CHAR, " ", s.dx(79), s.dx(6), s.dx(54), s.dx(34));
        cells[2][0] = new Cell(Cell.CELL_TYPE_CLR, null, s.dx(147), s.dx(6), s.dx(54), s.dx(34));

        // row 2-5
        createTallCells(cells, s);

        String top_img = prefix + "keyboard-top-tall.png";
    
        List<Element> list = createKeyboard(skin, s, f, BKeyboardPlus.TALL_KEYBOARD, cells, 
                top_img, null, 472,
                null, 0,
                null, 0,
                null, 1280, 58, 35, 0,
                null, 0, 0, 0, 0,
                211, 32, tivoWhite);
        
        Element topElement = list.get(0);
        topElement.set(IBananasPlus.P_KEYBOARD_THUMBS_UP, null);
        topElement.set(IBananasPlus.P_KEYBOARD_THUMBS_DOWN, null);
    }

    
    private static void createTallCells(Cell[][] cells, Scale s) {
        // row 2
        cells[0][1] = new Cell(Cell.CELL_TYPE_CHAR, "A", s.dx(11), s.dx(45), s.dx(44), s.dx(34));
        cells[1][1] = new Cell(Cell.CELL_TYPE_CHAR, "B", s.dx(60), s.dx(45), s.dx(44), s.dx(34));
        cells[2][1] = new Cell(Cell.CELL_TYPE_CHAR, "C", s.dx(110), s.dx(45), s.dx(44), s.dx(34));
        cells[3][1] = new Cell(Cell.CELL_TYPE_CHAR, "D", s.dx(157), s.dx(45), s.dx(44), s.dx(34));

        // row 3
        cells[0][2] = new Cell(Cell.CELL_TYPE_CHAR, "E", s.dx(11), s.dx(92), s.dx(44), s.dx(34));
        cells[1][2] = new Cell(Cell.CELL_TYPE_CHAR, "F", s.dx(60), s.dx(92), s.dx(44), s.dx(34));
        cells[2][2] = new Cell(Cell.CELL_TYPE_CHAR, "G", s.dx(110), s.dx(92), s.dx(44), s.dx(34));
        cells[3][2] = new Cell(Cell.CELL_TYPE_CHAR, "H", s.dx(157), s.dx(92), s.dx(44), s.dx(34));

        // row 4
        cells[0][3] = new Cell(Cell.CELL_TYPE_CHAR, "I", s.dx(11), s.dx(139), s.dx(44), s.dx(34));
        cells[1][3] = new Cell(Cell.CELL_TYPE_CHAR, "J", s.dx(60), s.dx(139), s.dx(44), s.dx(34));
        cells[2][3] = new Cell(Cell.CELL_TYPE_CHAR, "K", s.dx(110), s.dx(139), s.dx(44), s.dx(34));
        cells[3][3] = new Cell(Cell.CELL_TYPE_CHAR, "L", s.dx(157), s.dx(139), s.dx(44), s.dx(34));

        // row 5
        cells[0][4] = new Cell(Cell.CELL_TYPE_CHAR, "M", s.dx(11), s.dx(188), s.dx(44), s.dx(34));
        cells[1][4] = new Cell(Cell.CELL_TYPE_CHAR, "N", s.dx(60), s.dx(188), s.dx(44), s.dx(34));
        cells[2][4] = new Cell(Cell.CELL_TYPE_CHAR, "O", s.dx(110), s.dx(188), s.dx(44), s.dx(34));
        cells[3][4] = new Cell(Cell.CELL_TYPE_CHAR, "P", s.dx(157), s.dx(188), s.dx(44), s.dx(34));

        // row 6
        cells[0][5] = new Cell(Cell.CELL_TYPE_CHAR, "Q", s.dx(11), s.dx(236), s.dx(44), s.dx(34));
        cells[1][5] = new Cell(Cell.CELL_TYPE_CHAR, "R", s.dx(60), s.dx(236), s.dx(44), s.dx(34));
        cells[2][5] = new Cell(Cell.CELL_TYPE_CHAR, "S", s.dx(110), s.dx(236), s.dx(44), s.dx(34));
        cells[3][5] = new Cell(Cell.CELL_TYPE_CHAR, "T", s.dx(157), s.dx(236), s.dx(44), s.dx(34));

        // row 7
        cells[0][6] = new Cell(Cell.CELL_TYPE_CHAR, "U", s.dx(11), s.dx(283), s.dx(44), s.dx(34));
        cells[1][6] = new Cell(Cell.CELL_TYPE_CHAR, "V", s.dx(60), s.dx(283), s.dx(44), s.dx(34));
        cells[2][6] = new Cell(Cell.CELL_TYPE_CHAR, "W", s.dx(110), s.dx(283), s.dx(44), s.dx(34));
        cells[3][6] = new Cell(Cell.CELL_TYPE_CHAR, "X", s.dx(157), s.dx(283), s.dx(44), s.dx(34));

        // row 8
        cells[0][7] = new Cell(Cell.CELL_TYPE_CHAR, "Y", s.dx(11), s.dx(331), s.dx(44), s.dx(34));
        cells[1][7] = new Cell(Cell.CELL_TYPE_CHAR, "Z", s.dx(60), s.dx(331), s.dx(44), s.dx(34));
        cells[2][7] = new Cell(Cell.CELL_TYPE_CHAR, "0", s.dx(110), s.dx(331), s.dx(44), s.dx(34));
        cells[3][7] = new Cell(Cell.CELL_TYPE_CHAR, "1", s.dx(157), s.dx(331), s.dx(44), s.dx(34));

        // row 9
        cells[0][8] = new Cell(Cell.CELL_TYPE_CHAR, "2", s.dx(11), s.dx(380), s.dx(44), s.dx(34));
        cells[1][8] = new Cell(Cell.CELL_TYPE_CHAR, "3", s.dx(60), s.dx(380), s.dx(44), s.dx(34));
        cells[2][8] = new Cell(Cell.CELL_TYPE_CHAR, "4", s.dx(110), s.dx(380), s.dx(44), s.dx(34));
        cells[3][8] = new Cell(Cell.CELL_TYPE_CHAR, "5", s.dx(157), s.dx(380), s.dx(44), s.dx(34));

        // row 10
        cells[0][9] = new Cell(Cell.CELL_TYPE_CHAR, "6", s.dx(11), s.dx(427), s.dx(44), s.dx(34));
        cells[1][9] = new Cell(Cell.CELL_TYPE_CHAR, "7", s.dx(60), s.dx(427), s.dx(44), s.dx(34));
        cells[2][9] = new Cell(Cell.CELL_TYPE_CHAR, "8", s.dx(110), s.dx(427), s.dx(44), s.dx(34));
        cells[3][9] = new Cell(Cell.CELL_TYPE_CHAR, "9", s.dx(157), s.dx(427), s.dx(44), s.dx(34));   
    }
    
    private static void createEmailUrlLowercaseKeyboard(BSkinPlus skin, String prefix, 
            Scale s, Scale f, String name) {
        
        Cell cells[][] = new Cell[9][6];
        // row 1
        cells[0][0] = new Cell(Cell.CELL_TYPE_DEL, null, s.dx(12), s.dx(12), s.dx(58), s.dx(34));
        cells[1][0] = new Cell(Cell.CELL_TYPE_CLR, null, s.dx(84), s.dx(12), s.dx(90), s.dx(34));
        cells[2][0] = new Cell(Cell.CELL_TYPE_CHAR, " ", s.dx(184), s.dx(12), s.dx(65), s.dx(34));
        cells[3][0] = new Cell(Cell.CELL_TYPE_KEYBOARD, name + "-uppercase", s.dx(272), s.dx(12), s.dx(68), s.dx(34));
        cells[4][0] = new Cell(Cell.CELL_TYPE_KEYBOARD, name + "-symbol", s.dx(354), s.dx(12), s.dx(69), s.dx(34));

        // row 2-5
        createLowercaseCells(cells, s);

        // row 6
        String bottom_img;
        if (name.equals("email")) {
            createEmailCells(cells, s);
            bottom_img = prefix + "keyboard-bottom-email.png";
        } else {
            createUrlCells(cells, s);
            bottom_img = prefix + "keyboard-bottom-url.png";
        }

        String top_img = prefix + "keyboard-top-DELCLRSPC_ABC_SYM.png";
        String top_undo_img = prefix + "keyboard-top-DELUNDOSPC_ABC_SYM.png";
        String middle_img = prefix + "keyboard-middle-lc.png";
        String data_img = prefix + "keyboard-datafield.png";
        String tips_img = prefix + "keyboard-tips.png";
    
        createKeyboard(skin, s, f, name + "-lowercase", cells, 
                top_img, top_undo_img, 53,
                middle_img, 180,
                bottom_img, 77,
                data_img, 304, 54, 15, 7,
                tips_img, 207, 209, 16, 30,
                434, 32, tivoWhite);
    }
    
    private static void createEmailCells(Cell[][] cells, Scale s) {
        cells[0][5] = new Cell(Cell.CELL_TYPE_CHAR, "@", s.dx(13), s.dx(251), s.dx(45), s.dx(42));
        cells[1][5] = new Cell(Cell.CELL_TYPE_CHAR, ".com", s.dx(67), s.dx(251), s.dx(90), s.dx(42));
        cells[2][5] = new Cell(Cell.CELL_TYPE_CHAR, ".org", s.dx(165), s.dx(251), s.dx(75), s.dx(42));
        cells[3][5] = new Cell(Cell.CELL_TYPE_CHAR, ".net", s.dx(247), s.dx(251), s.dx(75), s.dx(42));
        cells[4][5] = new Cell(Cell.CELL_TYPE_CHAR, "_", s.dx(330), s.dx(251), s.dx(45), s.dx(42));
        cells[5][5] = new Cell(Cell.CELL_TYPE_CHAR, ".", s.dx(375), s.dx(251), s.dx(45), s.dx(42));
    }

    private static void createUrlCells(Cell[][] cells, Scale s) {
        cells[0][5] = new Cell(Cell.CELL_TYPE_CHAR, "_", s.dx(13), s.dx(252), s.dx(45), s.dx(42));
        cells[1][5] = new Cell(Cell.CELL_TYPE_CHAR, ".", s.dx(58), s.dx(252), s.dx(45), s.dx(42));
        cells[2][5] = new Cell(Cell.CELL_TYPE_CHAR, "/", s.dx(103), s.dx(252), s.dx(45), s.dx(42));
        cells[3][5] = new Cell(Cell.CELL_TYPE_CHAR, "~", s.dx(148), s.dx(252), s.dx(45), s.dx(42));
        cells[4][5] = new Cell(Cell.CELL_TYPE_CHAR, "-", s.dx(193), s.dx(252), s.dx(45), s.dx(42));
        cells[5][5] = new Cell(Cell.CELL_TYPE_CHAR, "?", s.dx(238), s.dx(252), s.dx(45), s.dx(42));
        cells[6][5] = new Cell(Cell.CELL_TYPE_CHAR, "&", s.dx(283), s.dx(252), s.dx(45), s.dx(42));
        cells[7][5] = new Cell(Cell.CELL_TYPE_CHAR, "=", s.dx(328), s.dx(252), s.dx(45), s.dx(42));
    }
    
    private static void createEmailUrlUppercaseKeyboard(BSkinPlus skin, String prefix, 
            Scale s, Scale f, String name) {
        
        Cell cells[][] = new Cell[9][7];
        
        // row 1
        cells[0][0] = new Cell(Cell.CELL_TYPE_DEL, null, s.dx(12), s.dx(12), s.dx(58), s.dx(34));
        cells[1][0] = new Cell(Cell.CELL_TYPE_CLR, null, s.dx(84), s.dx(12), s.dx(90), s.dx(34));
        cells[2][0] = new Cell(Cell.CELL_TYPE_CHAR, " ", s.dx(184), s.dx(12), s.dx(65), s.dx(34));
        cells[3][0] = new Cell(Cell.CELL_TYPE_KEYBOARD, name + "-lowercase", s.dx(272), s.dx(12), s.dx(68), s.dx(34));
        cells[4][0] = new Cell(Cell.CELL_TYPE_KEYBOARD, name + "-symbol", s.dx(354), s.dx(12), s.dx(69), s.dx(34));

        
        // row 2-5
        createUppercaseCells(cells, s);

        // row 6
        String bottom_img;
        if (name.equals("email")) {
            createEmailCells(cells, s);
            bottom_img = prefix + "keyboard-bottom-email.png";
        } else {
            createUrlCells(cells, s);
            bottom_img = prefix + "keyboard-bottom-url.png";
        }

        String top_img = prefix + "keyboard-top-DELCLRSPCabcSYM.png";
        String top_undo_img = prefix + "keyboard-top-DELUNDOSPCabcSYM.png";
        String middle_img = prefix + "keyboard-middle-uc.png";
        String data_img = prefix + "keyboard-datafield.png";
        String tips_img = prefix + "keyboard-tips.png";
    
        createKeyboard(skin, s, f, name + "-uppercase", cells, 
                top_img, top_undo_img, 53,
                middle_img, 180,
                bottom_img, 77,
                data_img, 304, 54, 15, 7,
                tips_img, 207, 209, 16, 30,
                434, 32, tivoWhite);
    }

    
    private static void createEmailUrlSymbolKeyboard(BSkinPlus skin, String prefix, 
            Scale s, Scale f, String name) {
        
        Cell cells[][] = new Cell[8][6];
        
        // row 1
        cells[0][0] = new Cell(Cell.CELL_TYPE_DEL, null, s.dx(12), s.dx(12), s.dx(58), s.dx(34));
        cells[1][0] = new Cell(Cell.CELL_TYPE_CLR, null, s.dx(84), s.dx(12), s.dx(90), s.dx(34));
        cells[2][0] = new Cell(Cell.CELL_TYPE_CHAR, " ", s.dx(184), s.dx(12), s.dx(65), s.dx(34));
        cells[3][0] = new Cell(Cell.CELL_TYPE_KEYBOARD, name + "-lowercase", s.dx(272), s.dx(12), s.dx(68), s.dx(34));
        cells[4][0] = new Cell(Cell.CELL_TYPE_KEYBOARD, name + "-uppercase", s.dx(354), s.dx(12), s.dx(69), s.dx(34));

        
        // row 2-5
        createSymbolCells(cells, s);

        // row 6
        String bottom_img;
        if (name.equals("email")) {
            createEmailCells(cells, s);
            bottom_img = prefix + "keyboard-bottom-email.png";
        } else {
            createUrlCells(cells, s);
            bottom_img = prefix + "keyboard-bottom-url.png";
        }

        String top_img = prefix + "keyboard-top-DELCLRSPCabcABC.png";
        String top_undo_img = prefix + "keyboard-top-DELUNDOSPCabcABC.png";
        String middle_img = prefix + "keyboard-middle-sym.png";
        String data_img = prefix + "keyboard-datafield.png";
        String tips_img = prefix + "keyboard-tips.png";
    
        createKeyboard(skin, s, f, name + "-symbol", cells, 
                top_img, top_undo_img, 53,
                middle_img, 180,
                bottom_img, 77,
                data_img, 304, 54, 15, 7,
                tips_img, 207, 209, 16, 30,
                434, 32, tivoWhite);
    }
    
    private static void createSymbolKeyboard(BSkinPlus skin, String prefix, Scale s, Scale f) {
        Cell cells[][] = new Cell[8][5];

        // row 1
        cells[0][0] = new Cell(Cell.CELL_TYPE_DEL, null, s.dx(12), s.dx(12), s.dx(58), s.dx(34));
        cells[1][0] = new Cell(Cell.CELL_TYPE_CLR, null, s.dx(84), s.dx(12), s.dx(90), s.dx(34));
        cells[2][0] = new Cell(Cell.CELL_TYPE_CHAR, " ", s.dx(184), s.dx(12), s.dx(65), s.dx(34));
        cells[3][0] = new Cell(Cell.CELL_TYPE_KEYBOARD, BKeyboardPlus.LOWERCASE, s.dx(272), s.dx(12), s.dx(68), s.dx(34));
        cells[4][0] = new Cell(Cell.CELL_TYPE_KEYBOARD, BKeyboardPlus.UPPERCASE, s.dx(354), s.dx(12), s.dx(69), s.dx(34));

        // row 2-5
        createSymbolCells(cells, s);

        String top_img = prefix + "keyboard-top-DELCLRSPCabcABC.png";
        String top_undo_img = prefix + "keyboard-top-DELUNDOSPCabcABC.png";
        String middle_img = prefix + "keyboard-middle-sym.png";
        String bottom_img = prefix + "keyboard-bottom-empty.png";
        String data_img = prefix + "keyboard-datafield.png";
        String tips_img = prefix + "keyboard-tips.png";
    
        createKeyboard(skin, s, f, BKeyboardPlus.SYMBOL, cells, 
                top_img, top_undo_img, 53,
                middle_img, 180,
                bottom_img, 17,
                data_img, 304, 54, 15, 7,
                tips_img, 207, 209, 16, 30,
                434, 32, tivoWhite);
    }
    
    private static void createSymbolCells(Cell[][] cells, Scale s) {
        // row 2
        cells[0][1] = new Cell(Cell.CELL_TYPE_CHAR, ".", s.dx(9), s.dx(58), s.dx(45), s.dx(42));
        cells[1][1] = new Cell(Cell.CELL_TYPE_CHAR, ",", s.dx(55), s.dx(58), s.dx(45), s.dx(42));
        cells[2][1] = new Cell(Cell.CELL_TYPE_CHAR, "@", s.dx(108), s.dx(58), s.dx(45), s.dx(42));
        cells[3][1] = new Cell(Cell.CELL_TYPE_CHAR, "~", s.dx(162), s.dx(58), s.dx(45), s.dx(42));
        cells[4][1] = new Cell(Cell.CELL_TYPE_CHAR, "#", s.dx(222), s.dx(58), s.dx(45), s.dx(42));
        cells[5][1] = new Cell(Cell.CELL_TYPE_CHAR, "&", s.dx(276), s.dx(58), s.dx(45), s.dx(42));
        cells[6][1] = new Cell(Cell.CELL_TYPE_CHAR, "(", s.dx(327), s.dx(58), s.dx(45), s.dx(42));
        cells[7][1] = new Cell(Cell.CELL_TYPE_CHAR, ")", s.dx(372), s.dx(58), s.dx(45), s.dx(42));
        
        // row 3
        cells[0][2] = new Cell(Cell.CELL_TYPE_CHAR, ":", s.dx(9), s.dx(103), s.dx(45), s.dx(42));
        cells[1][2] = new Cell(Cell.CELL_TYPE_CHAR, ";", s.dx(55), s.dx(103), s.dx(45), s.dx(42));
        cells[2][2] = new Cell(Cell.CELL_TYPE_CHAR, "*", s.dx(108), s.dx(103), s.dx(45), s.dx(42));
        cells[3][2] = new Cell(Cell.CELL_TYPE_CHAR, "?", s.dx(162), s.dx(103), s.dx(45), s.dx(42));
        cells[4][2] = new Cell(Cell.CELL_TYPE_CHAR, "!", s.dx(222), s.dx(103), s.dx(45), s.dx(42));
        cells[5][2] = new Cell(Cell.CELL_TYPE_CHAR, "_", s.dx(276), s.dx(103), s.dx(45), s.dx(42));
        cells[6][2] = new Cell(Cell.CELL_TYPE_CHAR, "[", s.dx(327), s.dx(103), s.dx(45), s.dx(42));
        cells[7][2] = new Cell(Cell.CELL_TYPE_CHAR, "]", s.dx(372), s.dx(103), s.dx(45), s.dx(42));
        
        // row 4
        cells[0][3] = new Cell(Cell.CELL_TYPE_CHAR, "'", s.dx(9), s.dx(151), s.dx(45), s.dx(42));
        cells[1][3] = new Cell(Cell.CELL_TYPE_CHAR, "\"", s.dx(55), s.dx(151), s.dx(45), s.dx(42));
        cells[2][3] = new Cell(Cell.CELL_TYPE_CHAR, "`", s.dx(108), s.dx(151), s.dx(45), s.dx(42));
        cells[3][3] = new Cell(Cell.CELL_TYPE_CHAR, "-", s.dx(162), s.dx(151), s.dx(45), s.dx(42));
        cells[4][3] = new Cell(Cell.CELL_TYPE_CHAR, "+", s.dx(222), s.dx(151), s.dx(45), s.dx(42));
        cells[5][3] = new Cell(Cell.CELL_TYPE_CHAR, "=", s.dx(276), s.dx(151), s.dx(45), s.dx(42));
        cells[6][3] = new Cell(Cell.CELL_TYPE_CHAR, "{", s.dx(327), s.dx(151), s.dx(45), s.dx(42));
        cells[7][3] = new Cell(Cell.CELL_TYPE_CHAR, "}", s.dx(372), s.dx(151), s.dx(45), s.dx(42));
        
        // row 5
        cells[0][4] = new Cell(Cell.CELL_TYPE_CHAR, "/", s.dx(9), s.dx(196), s.dx(45), s.dx(42));
        cells[1][4] = new Cell(Cell.CELL_TYPE_CHAR, "\\", s.dx(55), s.dx(196), s.dx(45), s.dx(42));
        cells[2][4] = new Cell(Cell.CELL_TYPE_CHAR, "|", s.dx(108), s.dx(196), s.dx(45), s.dx(42));
        cells[3][4] = new Cell(Cell.CELL_TYPE_CHAR, "^", s.dx(162), s.dx(196), s.dx(45), s.dx(42));
        cells[4][4] = new Cell(Cell.CELL_TYPE_CHAR, "%", s.dx(222), s.dx(196), s.dx(45), s.dx(42));
        cells[5][4] = new Cell(Cell.CELL_TYPE_CHAR, "$", s.dx(276), s.dx(196), s.dx(45), s.dx(42));
        cells[6][4] = new Cell(Cell.CELL_TYPE_CHAR, "<", s.dx(327), s.dx(196), s.dx(45), s.dx(42));
        cells[7][4] = new Cell(Cell.CELL_TYPE_CHAR, ">", s.dx(372), s.dx(196), s.dx(45), s.dx(42));
    }
    
    public static List<Element> createKeyboard(BSkinPlus skin, Scale s, Scale f, String name, Cell[][] cells, 
            String topImage, String topUndoImage, int topImageHeight, String middleImage, 
            int middleImageHeight, String bottomImage, int bottomImageHeight, String dataInputImage,
            int dataInputImageWidth, int dataInputImageHeight, int dataInputCap, int dataInputPadV, String tipsImage, 
            int tipsImageWidth, int tipsImageHeight, int tipsPadH, int tipsPadV, int imageWidth,
            int fontSize, Object color) {
        
        List<Element> list = new ArrayList<Element>(8);

        Element topElement = createImage(skin, s, name + IBananasPlus.H_KEYBOARD_TOP_IMAGE_SUFFIX, 
                imageWidth, topImageHeight, topImage);
        topElement.setObject("cells", cells);
        list.add(topElement);
        
        if (topUndoImage != null) { 
            list.add(createImage(skin, s, name + IBananasPlus.H_KEYBOARD_TOP_UNDO_IMAGE_SUFFIX, 
                    imageWidth, topImageHeight, topUndoImage));
        }

        if (middleImage != null) { 
            list.add(createImage(skin, s, name + IBananasPlus.H_KEYBOARD_MIDDLE_IMAGE_SUFFIX, 
                    imageWidth, middleImageHeight, middleImage));
        }

        if (bottomImage != null) { 
            list.add(createImage(skin, s, name + IBananasPlus.H_KEYBOARD_BOTTOM_IMAGE_SUFFIX, 
                    imageWidth, bottomImageHeight, bottomImage));
        }

        Element dataElement = createImage(skin, s, name + IBananasPlus.H_KEYBOARD_DATA_INPUT_IMAGE_SUFFIX, 
                dataInputImageWidth, dataInputImageHeight, dataInputImage);
        dataElement.setInt(IBananasPlus.P_CAP, dataInputCap);
        dataElement.setInt(IBananasPlus.P_PAD_V, dataInputPadV);
        list.add(dataElement);

        if (tipsImage != null) {
            Element tipsElement = createImage(skin, s, name + IBananasPlus.H_KEYBOARD_TIPS_IMAGE_SUFFIX, 
                    tipsImageWidth, tipsImageHeight, tipsImage);
            tipsElement.setInt(IBananasPlus.P_PAD_H, tipsPadH);
            tipsElement.setInt(IBananasPlus.P_PAD_V, tipsPadV);
            list.add(tipsElement);
        }

        list.add(new Element(skin, name + IBananasPlus.H_KEYBOARD_FONT_SUFFIX, 0, 0, 
                "default-" + f.dx(fontSize) + ".font"));
        
        list.add(new Element(skin, name + IBananasPlus.H_KEYBOARD_COLOR_SUFFIX, 0, 0, color));
        
        return list;
    }

    public static Element createImage(BSkinPlus skin, Scale s, String name, int width, int height, String resourceName) {
        return createImage(skin, s, name, width, height, null, resourceName);
    }
    
    public static Element createImage(BSkinPlus skin, Scale s, String name, int width, int height, String namespace, String resourceName) {
        if (s.isIdentity()) {
            return new Element(skin, name, width, height, resourceName);
        } else {
            if (resourceName != null) {
                return new ScaledImageElement(skin, name, s.dx(width), s.dx(height), namespace, resourceName);
            } else {
                return new Element(skin, name, s.dx(width), s.dx(height), resourceName);
            }
        }
        
    }
}
